import java.util.Arrays;

import java.util.Arrays;
public class test {
    public static void main(String[] args) {
        int[][] arr = {{1,2,3},{4,5,6}};
        System.out.println(Arrays.deepToString(arr));
    }
    public static void main13(String[] args) {
        int[][] arr = {{1,2,3},{4,5,6}};
        for (int[] x: arr) {
            for (int y: x) {
                System.out.print(y+" ");
            }
            System.out.println();
        }
    }
    public static void main12(String[] args) {
        int[][] arr = {{1,2,3},{4,5,6}};
        for (int i = 0; i < arr.length; i++) {
            for (int j = 0; j < arr[i].length; j++) {
                System.out.print(arr[i][j]+" ");
            }
            System.out.println();
        }
    }
    public static void main11(String[] args) {
        int[] arr = {1,2,3,4,5};
        int[] arr1 = new int[arr.length];
        System.arraycopy(arr,0,arr1,0,arr.length);
        System.out.println(Arrays.toString(arr1));
/*        int[] arr1 = Arrays.copyOfRange(arr,1,arr.length);
        System.out.println(Arrays.toString(arr1));*/

//        int[] arr1 = Arrays.copyOf(arr,arr.length+1);
    }
    public static void main10(String[] args) {
        int[] arr = {1,2,3,4};
        String tem = Arrays.toString(arr);
        System.out.println(tem);

    }
    public static void main9(String[] args) {
        int[][] arr = {{1,2,3},{4,5,6}};
/*        int[][] arr1 = new int[][]{{1,2,3},{4,5,6}};
        int[][] arr2 = new int[2][3];*/
       /* for (int i = 0; i < arr.length; i++) {
            for (int j = 0; j < arr[i].length; j++) {
                System.out.print(arr[i][j]+"  ");
            }
            System.out.println();
        }
        */
//        System.out.println(Arrays.deepToString(arr));
        for (int[] x: arr) {
            for (int y: x) {
                System.out.print(y+" ");
            }
            System.out.println();
        }
    }
    public static void main8(String[] args) {
        int[] arr = {2,4,6,3,4};
/*        arr = Arrays.copyOf(arr,arr.length*2);
        System.out.println(Arrays.toString(arr));
        int[] arr1 = Arrays.copyOf(arr,arr.length);
        System.out.println(Arrays.toString(arr1));
        int[] arr2 = Arrays.copyOfRange(arr,0,4);
        System.out.println(Arrays.toString(arr2));*/
        int[] old = new int[arr.length];
        System.arraycopy(arr,0,old,0,arr.length);
        System.out.println(Arrays.toString(old));
    }

    public static void main7(String[] args) {
        int[] arr = {2,4,6,3,4};
        if(Odd(arr)) {
            System.out.println("拥有三个连续奇数");
        } else {
            System.out.println("不拥有三个连续奇数");
        }
    }
    public static boolean Odd(int[] arr) {
        int count = 0;
        for (int i = 0; i < arr.length; i++) {
            if(arr[i]%2==0) {
                count = 0;
            }
            if(arr[i]%2==1&&count<3) {
                count++;
            }
            if(count==3) {
                return true;
            }
        }
        return false;
    }
    public static void main6(String[] args) {
        int[] arr = {1,2,2,3,4,5,2};
        System.out.println(MostHalf(arr));
    }
    public static int MostHalf(int[] arr) {
        Arrays.sort(arr);
        return arr[arr.length/2];
    }
    public static void main5(String[] args) {
        for (int i = -1; i < -1; i++) {
            System.out.println("666");
        }
    }
    public static void main4(String[] args) {
        int[] arr = {1,2,3,4,5,6};
        if(FindIndex(arr,5)!=-1)
        System.out.println(arr[FindIndex(arr,5)]);
        if(FindIndex(arr,6)!=1)
            System.out.println(arr[FindIndex(arr,6)]);
        System.out.println(Arrays.binarySearch(arr,6));
    }
    public static int FindIndex(int[] arr, int num) {
        int i = 0;
        int j = arr.length-1;
        while (i<=j) {
            int mid = (i+j)/2;
            if(arr[mid]>num) {
                j = mid-1;
            } else if(arr[mid]==num) {
                return mid;
            } else {
                i = mid+1;
            }
        }
        return -1;
    }
    public static void main3(String[] args) {
        int[] arr = {2,7,3,4,5,6};
        System.out.println(Arrays.toString(arr));
        arr = chg1(arr);
        System.out.println(Arrays.toString(arr));
        System.out.println();
        int[] arr1 = {2,7,3,4,5,6};
        arr1 = chg2(arr1);
        System.out.println(Arrays.toString(arr1));
    }
    public static int[] chg1(int[] arr) {
        int front = 0;
        int back = arr.length-1;
        while (front<back) {
            if(arr[front]%2==1) {
                front++;
                continue;
            }
            if(arr[back]%2==0) {
                back--;
                continue;
            }
            if(arr[front]%2==0&&arr[back]%2==1) {
                int tem = arr[front];
                arr[front] = arr[back];
                arr[back] = tem;
            }
        }
        return arr;
    }
    public static int[] chg2(int[] arr) {
        int big = 0;
        int small = 0;
        while (big<arr.length) {
            if(arr[big]%2==0&&arr[small]%2!=0) {
                small = big;
            }
            if(arr[big]%2!=0&&arr[small]%2==0) {
                if(big==small) {
                    continue;
                }
                int tem = arr[small];
                arr[small] = arr[big];
                arr[big] = tem;
                small = big;
            }
            big++;
        }
        return arr;
    }
    public static void main2(String[] args) {
        int[] arr = {1,2,3};
        System.out.println(Arrays.toString(arr));
        arr = Double(arr);
        System.out.println(Arrays.toString(arr));
    }
    public static int[] Double(int[] arr) {
        for (int i = 0; i < arr.length; i++) {
            arr[i] *= 2;
        }
        return arr;
    }
    public static void main1(String[] args) {
        hanio(3,'A','B','C');
        System.out.println();
    }
    public static void Print(char pos1, char pos2) {
        System.out.print(pos1+"->"+pos2+" ");
    }

    public static void hanio(int n, char pos1, char pos2, char pos3) {
        if(n==1) {
            Print(pos1,pos3);
            return;
        }
        hanio(n-1,pos1,pos3,pos2);
        Print(pos1,pos3);
        hanio(n-1,pos2,pos1,pos3);
    }
    /**
     *
     * @param n 几个盘子
     * @param pos1 起始位置
     * @param pos2 中转位置
     * @param pos3 终点位置
     */
/*    public static void hanio(int n, char pos1, char pos2, char pos3) {
        if(n==1) {
            Print(pos1,pos3);
            return;
        }
        hanio(n-1,pos1,pos3,pos2);
        Print(pos1,pos3);
        hanio(n-1,pos2,pos1,pos3);
    }*/
}
